<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/30
 * Time: 10:46
 */

namespace app\index\common;


use app\index\service\DataReturnService as DRS;
use think\Db;

class Base
{
    public static function getUserByTokenWithPhone($token)
    {
        $token = DB::table('token')->where(['token_value' => $token])->find();
        if(empty($token))
        {
            return DRS::returnError(1110,'登录失效！');
        }else{
            $user_data = Db::table('users')
                ->alias('u')
                ->join('business b','u.id = b.business_id')
                ->field('u.id,u.system_id,u.is_business,u.name,u.state,u.grade,u.agent,u.shop,u.is_staff,u.is_address,u.phone,u.card_balance,u.enjoy_currency,u.is_identity,u.createtime,u.last_login_time,b.is_auth')
                ->where(['u.id' => $token['user_id']])
                ->find();
            if(empty($user_data))
            {
                return DRS::returnError(1010,'该用户不存在！');
            }
            return DRS::returnOk($user_data,'ok');
        }
    }

}